至script內新增程式碼
1
2
3
4
5
6
7
8
9
10
11
12
13
|
threadFunction= function () sim.setThreadSwitchTiming(2) -- Default timing for automatic thread switching -- Here we execute the regular thread code: res,err= xpcall (threadFunction, function (err) return debug.traceback (err) end ) if not res then sim.addStatusbarMessage( 'Lua runtime error: ' ..err) end -- Put some clean-up code here: simRemoteApi.start(19997) end |
到V-REP資料夾→programming→remoteApiBindings→python→python中複製
vrep.py
vrepConst.py
跟programming→remoteApiBindings→lib→lib→Windows→64Bit中複製
remoteApi.dll
到你要存程式的資料夾中
打開wscite並輸入以下程式碼(小白球)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import vrep import sys, math # child threaded script: # 內建使用 port 19997 若要加入其他 port, 在 serve 端程式納入 #simExtRemoteApiStart(19999) vrep.simxFinish( - 1 ) clientID = vrep.simxStart( '127.0.0.1' , 19997 , True , True , 5000 , 5 ) if clientID! = - 1 : print ( "Connected to remote server" ) else : print ( 'Connection not successful' ) sys.exit( 'Could not connect' ) |
存成→檔名.py
並執行
如果執行結果為
Connected to remote server
>Exit code: 0
那就可以進行連動